import { defineStore } from "pinia";

export const userStore = defineStore("user", {
  state: () => ({
    title: "itlove",
    count: 1,
  }),
  getters: {
    changeCount() {
      return this.count + 10;
    },
  },
  actions: {
    addCount(v) {
      this.count += v;
    },
  },
  persist: {
    enabled: true, //开启
    strategies: [
      //个性化配置
      {
        key: "user", //默认当前 Store的id
        storage: sessionStorage, //存储的方式
        paths: ["count"], //可以选择持久化的的字段
      },
    ],
  },
});
